package com.gujia.designpattern;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class Test implements TestInterface{
    public void example(){
        System.out.println("example");
    }


    public static void main(String[] args) {
        Test test = new Test();

        InvocationHandler handler = new PrintHandler(test);
        Class<?> cls = test.getClass();

        TestInterface testInterface = (TestInterface)Proxy.newProxyInstance(cls.getClassLoader(),cls.getInterfaces(),handler);

        testInterface.example();
    }
}
